<template>
  <div>
    <el-dialog title="添加行业信息" :visible.sync="visible">
      <el-form :model="deviceType">
        <el-form-item label="行业名称" :label-width="formLabelWidth">
          <el-input v-model="deviceType.name" autocomplete="off"></el-input>
        </el-form-item>
        <template>
          <el-select v-model="deviceType.industryId" placeholder="请选择设备行业">
            <el-option
                v-for="deviceType in list"
                :key="deviceType.industryId"
                :label="deviceType.name"
                :value="deviceType.industryId">
            </el-option>
          </el-select>
        </template>
        <template>
          <el-select v-model="deviceType.deviceType" placeholder="请选择设备类型">
            <el-option
                v-for="deviceType in devicesTypeBean.list"
                :key="deviceType.deviceType"
                :label="deviceType.name"
                :value="deviceType.deviceType">
            </el-option>
          </el-select>
        </template>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="visible = false">取 消</el-button>
        <el-button type="primary" @click="fnAdd">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
export default {
  name: "DeviceTypeAdd",
  props:{
    list:[],
    devicesTypeBean:{
    }
  },
  data() {
    return {
      visible: false,
      deviceType: {
        name: '',
        industryId:'',
        deviceType:''
      },
      formLabelWidth: '120px'
    }
  }
  ,
  methods: {
    fnAdd() {
      this.axios.post("http://localhost:8080/devices/devicesInsert/", this.deviceType).then(resp => {
        if (resp.data.code === "200") {
          this.$message.success("添加行业信息成功");
          this.visible = false;
          this.$emit('closed');
        } else {
          this.visible = false;
          this.$message.error(resp.data.desc);
        }

      })
    }
  },
}
</script>

<style scoped>

</style>
